﻿
'Documentation - The code below here is from a site called - www.ctrfx.com/form/ 
'This is the page and ContactUs - vaildidation, buttons, labels and textboxes  that I have used the code from that site. -  - www.ctrfx.com/form/ 

Imports System.Net.Mail
Public Class ContactUs
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click

        Dim feedBack As New MailMessage()
        feedBack.[To].Add("mercedesclassccars@hotmail.co.uk")
        feedBack.From = New MailAddress("mercedesclassccars@hotmail.co.uk")
        feedBack.Subject = txtSubject.Text

        feedBack.Body = (("Sender Name: " + txtName.Text & "<br><br>Sender Email: ") + txtMail.Text & "<br><br>") + txtMessage.Text
        feedBack.IsBodyHtml = True
        Dim smtp As New SmtpClient()
        smtp.Host = "smtp.live.com"
        'Or Your SMTP Server Address
        smtp.Port = 587
        smtp.EnableSsl = True
        smtp.Credentials = New System.Net.NetworkCredential("mercedesclassccars@hotmail.co.uk", "testing123")
        'Or your Smtp Email ID and Password
        smtp.Send(feedBack)
        Label1.Text = "Thanks for contacting us"


        ' I have written this to clear the textboxes up after the user sent his email. 
        txtName.Text = ""
        txtSubject.Text = ""
        txtMessage.Text = ""
        txtMail.Text = ""
    End Sub


End Class